package com.plug.common.model;

import com.plug.common.consts.Code;

import java.util.HashMap;
import java.util.Map;

/**
 * Json 返回结果模型
 *
 * @author Archx[archx@foxmail.com]
 * @date 2016/3/21 0021
 */
public class JsonResult extends AbstractResult {

    private static final long serialVersionUID = 7971943543786064771L;

    /**
     * 自定义属性
     */
    private Map<String, Object> data;

    /**
     * 自定义返回对象
     */
    private Object object;

    public JsonResult() {
        setCode(Code.SUCCESS);
        setMessage("OK");
    }

    public Map<String, Object> getData() {
        return data;
    }

    public void setData(Map<String, Object> data) {
        this.data = data;
    }

    public Object getObject() {
        return object;
    }

    public void setObject(Object object) {
        this.object = object;
    }

    /**
     * 增加数据
     *
     * @param key   key
     * @param value value
     * @return this
     */
    public JsonResult putData(String key, Object value) {
        if (data == null)
            data = new HashMap<>();
        data.put(key, value);
        return this;
    }
}
